/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package marshall;

import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

/**
 *
 * @author tiz
 */
public class GenXML {

    public GenXML() {}

    public static void mar(Object obj, String filePath) {
        try {
            JAXBContext jc = JAXBContext.newInstance(obj.getClass());
            Marshaller mar = jc.createMarshaller();
            mar.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
            mar.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            mar.marshal(obj, new File(filePath));
        } catch (JAXBException e) {
            e.printStackTrace();
        }
    }

}
